package com.ta.gulimall.product.service.impl;

import com.ta.gulimall.product.view.pto.SpuDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ta.gulimall.product.dao.SpuImagesDao;
import com.ta.gulimall.product.view.entity.SpuImagesEntity;
import com.ta.gulimall.product.service.SpuImagesService;


@Service("spuImagesService")
public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEntity> implements SpuImagesService {

    @Override
    public void saveSpuImages(SpuDto spuDto, List<String> images) {
        List<SpuImagesEntity> spuimages = images.stream()
                .map(m -> SpuImagesEntity.builder().spuId(spuDto.getSpuId()).imgUrl(m).build())
                .collect(Collectors.toList());

        this.saveBatch(spuimages);
    }

}